/* ************************************************************************************************

	Copyright (c) 2005-2006, IGR
	All Rights Reserved.
	Licensed under the Apache License version 2.0 or above.
	For more information on licensing, see:
        http://www.apache.org/licenses/


 ************************************************************************************************
 Objet type TOOLBAR
 VERSION:0.85
 DATE:16/03/2006
 ************************************************************************************************
 objPar    object of parameter with possible value
	 Name:               toolbar name
	 top:           	 Top position (in pixel)
	 left:               Left position (in pixel)             
	 width:              Width 
	 height				 Height
	 parent              object parent


 ************************************************************************************************/

// *************************************
// CONSTRUCTOR
// *************************************

rialto.widget.ToolBar=function(objPar){

	//base constructor
    this.base = rialto.widget.AbstractContainer;
    objPar.type="toolbar";
    this.base(objPar);
         
    //Default value

   
    //set the value with the properties of the objPar object
    if (objPar){         
    }

    var oThis=this;    
    
    // *******************************************
	// GENERATION OF DOM ELEMENTS
	// *******************************************
	this.divExt.style.top = this.top;
    this.divExt.style.left = this.left;
    this.divExt.style.width = this.width;        
    //this.divExt.style.height = "25px";
    this.divExt.style.position="absolute";//this.position;         
        
	this.divExt.className="toolBarDiv";
	this.imgG=document.createElement("DIV")
    this.imgG.className="leftEdgeToolbar";
    this.imgD=document.createElement("DIV")
    this.imgD.className="rightEdgeToolbar";    

    this.divExt.appendChild(this.imgG);
    this.divExt.appendChild(this.imgD);
    
    if (objPar.parent) {this.placeIn(objPar.parent);};
    
    //addEvent handler
    this.divExt.ondblclick=function(e){
        var ev=e?e:window.event;
        oThis.ondbleclick(ev);    
    };
/*    this.divExt.onclick=function(e){
        var ev=e?e:window.event;
        oThis.click(ev);    
    };
   */
    
    //release object
	objPar=null;
	
}

rialto.widget.ToolBar.prototype = new rialto.widget.AbstractContainer;





rialto.widget.ToolBar.prototype.addText=function(top,left,text,classname){
	var textWidth=getTailleTexte(text,"libelle1");
	var div=document.createElement("DIV");
	div.className="libelle1";
	div.style.top = 2;
    //div.style.left =left;

    div.style[ATTRFLOAT] ='left';
    div.style.position ='relative';
    div.style.width = textWidth; 
    div.innerHTML=text;   
    this.divExt.appendChild(div);
    return div;
}


rialto.widget.ToolBar.prototype.addSpace=function(){
	
	var div=document.createElement("DIV");
    div.style.width =20;
    div.style.height ="100%";
//    div.style.backgroundColor ="red";
    div.style[ATTRFLOAT] ='left';
    div.style.position ='relative';
    this.divExt.appendChild(div);
    
}

rialto.widget.ToolBar.prototype.addSeparation=function(){

	var div=document.createElement("DIV");
    div.className="cellSep";
    div.style[ATTRFLOAT] ='left';
    div.style.position ='relative';
    this.divExt.appendChild(div);
}

rialto.widget.ToolBar.prototype.addMenu=function(title,menu){
	
	
	var oThis=this;
	div=this.addText('','',title);
	
	div.onmouseover=function(){
		this.style.height=parseInt(this.offsetHeight)-2;
		//this.style.top=parseInt(this.style.top)-2;
		this.style.border="1px solid cyan";
	}
	div.onmouseout=function(){
		this.style.border=null;
		this.style.height=parseInt(this.offsetHeight)+2;		
	}
	
	div.onclick=function(){
		menu.setPosTop(compOffsetTop(oThis.divExt)+22);
    	menu.setPosLeft(compOffsetLeft(oThis.divExt)+2);
    	//open the list
    	menu.affichezoneMenu(evt=null,heightCombo=22);
	}
	

	
	this.addSpace();
	
}

rialto.widget.ToolBar.prototype.addButton=function(obj){

	ob={position:'relative',boolFloatLeft:true}
	var but= new rialto.widget.Image("printButtonOff",0,2,this,"Print the content","printButtonOn",ob);                
	this.addSpace();          
	return but;
}


rialto.widget.ToolBar.prototype.release=function(){
	this.divExt.ondblclick=null;
	var childDivs = this.divExt.childNodes;
    for (var lnIdx=0;lnIdx<childDivs.length;lnIdx++){
        var childDiv = childDivs[lnIdx];
        childDiv.onmouseover=null;
        childDiv.onmouseout=null;
        childDiv.onclick=null;
    }
}

